//
//  CYAccountTitleCell.m
//  CaiYun
//
//  Created by 今日信息科技 on 2017/8/14.
//  Copyright © 2017年 今日信息科技. All rights reserved.
//

#import "CYAccountTitleCell.h"

@interface CYAccountTitleCell()
@property (nonatomic, strong) CYImageView *selectedImg;
@end
@implementation CYAccountTitleCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setSeparatorInset:UIEdgeInsetsMake(0.0, AL(PT(35)), 0.0, AL(PT(35)))];
        [self setLayoutMargins:UIEdgeInsetsMake(0.0, AL(PT(35)), 0.0, AL(PT(35)))];
    }
    return self;
}

- (CYImageView *)selectedImg{
    if (!_selectedImg) {
        _selectedImg = [[CYImageView alloc]initWithImageName:@"gray" size:CGSizeMake(AL(10), AL(8)) isRadius:NO];
        [self addSubview:_selectedImg];
        
        WS(self)
        [_selectedImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(weakSelf.mas_right).with.offset(- AL(PT(30)));
            make.centerY.equalTo(weakSelf);
            make.size.mas_equalTo(CGSizeMake(AL(10), AL(8)));
        }];
    }
    return _selectedImg;
}

- (void)setTitle:(NSString *)title{
    if (_title != title) {
        _title = title;
        self.textLabel.text = title;
        self.textLabel.font = [UIFont systemFontOfSize:AL(PT(32))];
        self.textLabel.textColor = ColorHex(0x888888);
        self.selectedImg.hidden = NO;
    }
}

- (void)setSelectText:(NSString *)selectText{
    if (_selectText != selectText) {
        _selectText = selectText;
        self.textLabel.textColor = ([selectText isEqualToString:@"YES"])?ColorHex(0x333333):ColorHex(0x888888);
        self.selectedImg.image = ([selectText isEqualToString:@"YES"])?[UIImage imageNamed:@"red"]:[UIImage imageNamed:@"gray"];
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
